<template>
	<div class="alertBox giveSetBox">
		<div class="alertBk"></div>
		<div class="wordBox">
			<div class="alertHead">
				<p class="tittle">发送规则设置</p>
				<div class="myClose" @click="closeGiveSet">
					<img src="~_assets/close.png" class="myClose" />
				</div>
				<span class="checkTxt" v-show="diffRule" style="right:60%;top:0">与初录不一致</span>
			</div>
			<div class="alertBody">
				<div class="changeDiv">
					<el-radio v-model="radio2" label="1">百分比中奖</el-radio>
					<el-input placeholder="" v-model.trim="input2" class="setInput" clearable  :disabled="hideDiv">
					</el-input>/100000
				</div>
				<div class="hintText">请输入0～100000作为分子，输入数越大，概率越大</div>
				<div class="changeDiv">
					<el-radio v-model="radio2" label="2">老用户回归</el-radio>
					参加用户:
					<el-select v-model="value2" placeholder="" class="setSelect"  :disabled="!hideDiv">
						<el-option v-for="item in options2" :key="item.value" :label="item.label" :value="item.value">
						</el-option>
					</el-select>
					<el-select v-model="value3" placeholder="" class="setSelect"  :disabled="!hideDiv">
						<el-option v-for="item in options3" :key="item.value" :label="item.label" :value="item.value">
						</el-option>
					</el-select>
				</div>
				<div class="alertBut">
					<button class="isFalse" @click="closeGiveSet(0)">取消</button>
					<button class="isTrue" @click="closeGiveSet(1)">确认</button>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				radio2: '1',
				input2: 0,
				value2: '7',
				value3: '0',
				options2: [{
					value: '7',
					label: '7日'
					}, {
						value: '15',
						label: '15日'
					}, {
						value: '30',
						label: '30日'
					}, {
					value: '90',
					label: '90日'
				}],
				options3: [{
					value: '0',
					label: '未充电'
				}],
				hideDiv:false,//不可操作
				diffRule:false,
			}
		},
		methods: {
			closeGiveSet(type) {
				if(type == 1){
					let item = {}
					if(this.radio2 == '1'){
						item.addsWinning = this.input2
						item.triggerData = null
						item.triggerCondition = this.value3
					}else{
						item.addsWinning = null
						item.triggerData = this.value2
						item.triggerCondition = this.value3
					}
					this.$emit('closeGiveSet',item)
				}else{
					this.$emit('closeGiveSet')
				}
			}
		},
		watch:{
			radio2(val){
				this.hideDiv = val != 1
			},
			input2(val){
				val = Number(val)
				if(isNaN(val)){
					this.input2 = 0
					this.$message({
						message: '请输入0~100000整数',
						type: 'warning'
					})
				}
			}
		}
	}
</script>

<style>
	.giveSetBox .setInput {
		margin-left: 0;
		width: 20%;
	}
	.giveSetBox .el-select{
		width:25%;
	}
	.hintText{
		font-size:14px;
		font-family:PingFangSC-Regular;
		font-weight:400;
		color:rgba(255,46,46,1);
		margin-top: -15px;
		margin-bottom: 10px;
		margin-left: 31%;
	}
</style>